package com.zhentao.pojo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;

/**
 * 号源表
 * @TableName source
 */
@TableName(value ="source")
@Data
public class Source implements Serializable {
    /**
     * 号源ID
     */
    @TableId(type = IdType.AUTO)
    private Long sourceId;

    /**
     * 关联排班ID（关联schedule表）
     */
    private Long scheduleId;

    /**
     * 剩余号数（初始=total_num，预约后递减）
     */
    private Integer remainNum;

    /**
     * 放号时间（如：07:00:00开始放号）
     */
    private Date releaseTime;

    /**
     * 号源状态（1-可预约 0-不可预约）
     */
    private Integer sourceStatus;

    /**
     * 乐观锁版本（防止并发超卖）
     */
    private Integer version;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        Source other = (Source) that;
        return (this.getSourceId() == null ? other.getSourceId() == null : this.getSourceId().equals(other.getSourceId()))
            && (this.getScheduleId() == null ? other.getScheduleId() == null : this.getScheduleId().equals(other.getScheduleId()))
            && (this.getRemainNum() == null ? other.getRemainNum() == null : this.getRemainNum().equals(other.getRemainNum()))
            && (this.getReleaseTime() == null ? other.getReleaseTime() == null : this.getReleaseTime().equals(other.getReleaseTime()))
            && (this.getSourceStatus() == null ? other.getSourceStatus() == null : this.getSourceStatus().equals(other.getSourceStatus()))
            && (this.getVersion() == null ? other.getVersion() == null : this.getVersion().equals(other.getVersion()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getSourceId() == null) ? 0 : getSourceId().hashCode());
        result = prime * result + ((getScheduleId() == null) ? 0 : getScheduleId().hashCode());
        result = prime * result + ((getRemainNum() == null) ? 0 : getRemainNum().hashCode());
        result = prime * result + ((getReleaseTime() == null) ? 0 : getReleaseTime().hashCode());
        result = prime * result + ((getSourceStatus() == null) ? 0 : getSourceStatus().hashCode());
        result = prime * result + ((getVersion() == null) ? 0 : getVersion().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", sourceId=").append(sourceId);
        sb.append(", scheduleId=").append(scheduleId);
        sb.append(", remainNum=").append(remainNum);
        sb.append(", releaseTime=").append(releaseTime);
        sb.append(", sourceStatus=").append(sourceStatus);
        sb.append(", version=").append(version);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}